<?php
       $pdo = new PDO("mysql:host=127.0.0.1;dbname=yii",'root','root');
        //引入querylist
	    require "../QueryList/vendor/autoload.php";
        use QL\QueryList;
	    set_time_limit(0);
        
	    for ($i=3; $i < 6; $i++) { 
	    	$url = "http://baidu.lecai.com/lottery/draw/list/".$i;

	     $rule = array(
              'time'=>array(".td1",'text'),
              'qi'  =>array(".td2 a",'text'),
              'num' =>array(".td3 .ball_1",'text'),
	     	);
	     $data[$i] = QueryList::query($url,$rule,'tbody tr')->data;
	    foreach ($data as $key => $value) {
           foreach ($value as $k => $v) {
           //print_r($v);die;
	       $sql ="insert into lottery values(null,'".$v['time']."','".$v['qi']."','".$v['num']."','".$key."')";
	   // echo $sql;die;
	       $pdo->exec($sql); 
         }
	     
	  }
	
	     
	 }
	
	
	 
	
	 



